package it.low.game.client.gui.input;

import it.low.game.client.gui.command.Command;

public class Input {

	public static enum EXEC {SELECT,TOGGLE,HOLD}
	
	private EXEC exec = null;
	
	private String input = null;
	private Command[] commands = null;
	private int maxCommands = 0;
	private int selCommand = 0;
	//private boolean isSelected = false;
	 
	
	public Input(String input, EXEC exec, Command... commands){
		this.input = input;		
		this.exec = exec;
		this.commands = commands;
		this.maxCommands = commands.length;
	}
	
	public String getInput(){
		return this.input;
	}
	
	public EXEC getInputExec(){
		return this.exec;
	}
	
	public void resetInput(){
		this.selCommand = 0;
		//this.isSelected = false;
	}
	
	public void pressInput(){
		switch(this.getInputExec()){
			case SELECT : this.selectInput(); break;
			case TOGGLE : this.toggleInput(); break;
			case HOLD : this.holdInput(); break;				
		}		
	}
	
	public void relaseInput(){
		switch(this.getInputExec()){
			case SELECT : break;
			case TOGGLE : break;
			case HOLD : break;				
		}
	}
	
	private void selectInput(){
		this.executeCommand();
	}
	
	private void toggleInput(){
		this.executeCommand();
		this.selCommand = getNextCommand();		
	}
	
	private void holdInput(){
		this.executeCommand();
	}
	
	private int getNextCommand(){
		selCommand = (++selCommand == maxCommands?0:selCommand);
		return selCommand;
	}
	
	private void executeCommand(){
		commands[selCommand].execute();
	}
	
//	private void deselectInput(){
//		//this.isSelected = false;
//		this.terminateCommand();
//	}
	
	
	
//	private void terminateCommand(){
//		commands[selCommand].terminate();
//	}
	
	
	
}
